#include<iostream>
#include<vector>
#include<string>
using namespace std;

struct Person
{
    string name;
    int age;
    
};

vector<Person> v;
void mysort(int* arr,int len)
{
    for(int i = 0;i < len;i++)
    {
        for(int j = 0;j < len - i;j++)
        {
            if(arr[j] > arr[j + 1])
            {
                auto temp = v.at(j);
                v.at(j) = v.at(j+1);
                v.at(j+1) = v.at(j);
            }
        }
    }
    
}
void printVector()
{
    cout << "以下是按年龄排序后的信息：" << endl;
    for(int i = 0;i < v.size();i++)
    {
        cout << "姓名： " << v.at(i).name << "年龄： " << v.at(i).age;
        cout << endl;
    }
}
void person(Person p,int age,string name)
{
    p.age = age;
    p.name = name;
    v.push_back(p);
}

int main()
{
    
    int num,age;
    string name;
    cout << "请设置你要储存人员信息的个数：" << endl;
    cin >> num;
    int arr[num];
    for(int i = 0;i < num;i++)
    {
        Person p;
        cout << "请输入要储存人员的年龄信息：" << endl;
        cin >> age;
        
        cout << "请输入要储存人员的姓名信息：" << endl;
        cin >> name;
        person(p,age,name);
        arr[i] = p.age;
    }
    int len = sizeof(arr) / sizeof(int);
    mysort(arr,len);
    printVector();
    
}